Show all User accounts in a terminal window

Hi Community,


which CLI command give me a list of all Users of a system?


Thx & Bye Tom

Posted on Feb 16, 2013 3:09 PM

Reply
12 replies

Feb 16, 2013 4:25 PM in response to prontosystems

As red_menace shows you can get a raw list of accounts, however many of them are for daemons or specific system file ownership but are not what you might call interactive users. May of them may never be used as your system is not in the correct environment (such as 'nobody' which is typically assigned to a guest NFS user, assuming you were exporting a file system via NFS, which very few Mac OS X users actually do).


You might try using


dscl . list /users shell | grep -v false


which will narrow down the list of users a lot.


Then eliminate _uucp, as the "Unix to Unix Copy" facilities are very old and a mystery to setup (I did it once back in '87 on some PDP-11s running AT&T UNIX System V.2, but it was strange even then).


You should be left with:


Guest
root
your_short_username
any_other_accounts_you_created_on_this_mac

Feb 17, 2013 6:46 AM in response to BobHarris

Hi Bob,


okay thanks for your explanation. Without the filter argument I see a list of users like I would see in Linux /etc/passwd. I found a couple of arguments for the dscl command like UniqueID etc and this was what I searched. One more question: Where or in which files are this information's stored? Is there a preferences file or something like that?


Thx & Bye Tom

Feb 17, 2013 11:41 AM in response to softwater

Hi,


softwater wrote:


The simplest way to get a list of users with 'home' folders is just to type


ls /Users/


in Terminal.


this isn't true because a User home directory could be restored from a Time Machine backup without existing the corresponding User on the system. In my case a user did a clean install and restored the users from the old system from a time machine backup but a login failed. With the dscl command I'm able to find out if the user really exists on the system or if only the home directory is present.


Thx & Bye Tom

Feb 17, 2013 11:49 AM in response to BobHarris

Hi,

BobHarris wrote:


It might be /var/db/dslocal/nodes/Default/users/*, but I'm am unsure. I did find a bunch of .plist files there that included my account name, and a bunch of the other names from the "dscl . list /Users" command. But that could be something else too :-)


yes I guess that this information's are stored very deep and in multiple files in the system. Nothing with keep it simple and stupid. In Linux I migrate the users from one system to another by moving the /etc/passwd, /etc/shadow and /etc/group file to the new system. It could be just that simple... ;-)


Thx & Bye Tom

Mar 22, 2016 6:55 AM in response to prontosystems

prontosystems wrote:


Where or in which files are this information's stored? Is there a preferences file or something like that?


OS X user data is stored in an LDAP database. Either a file-based LDAP database running locally and with no networking required (the dslocal stuff), or the user data is stored LDAP servers accessed via and running on the network, or the data is stored both in parallel.


If you want to rummage the data, use the dscl tool and/or the LDAP programming interfaces or related. These tools will deal with figuring out what data is stored where, and on any particular system. Whether that data is either stored entirely locally, or in an Open Directory or Active Directory database, or otherwise.

Oct 7, 2016 9:07 AM in response to prontosystems

Nothing with keep it simple and stupid. In Linux I migrate the users from one system to another by moving the /etc/passwd, /etc/shadow and /etc/group file to the new system

It's even simpler. Nightly the dslocal and shadow directories are backed up. Restore /private/var/db/dslocal-backup.xar and /private/var/db/shadow-backup.xar from your backup. This should be done in Single User mode.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Show all User accounts in a terminal window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.